
let local_token = sessionStorage.user_token;

export default {

    namespaced: true,

    state: {
        user_token : local_token
    },

    mutations: {

        setToken(state, token){
            state.user_token = token;
            sessionStorage.setItem('user_token',token);
        },

        deleteToken(state){
            state.user_token = null;
            sessionStorage.removeItem('user_token');
        }

    },

    actions: {
        toSetToken({ state, commit, rootState }, token) {
            commit('setToken', token);
        }
    },

    getters: {
        getToken (state){
            return state.user_token;
        }
    }
};